package pailaidai.hc.com.mysvgdemo.activity;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TableLayout;

import java.util.ArrayList;
import java.util.List;

import pailaidai.hc.com.mysvgdemo.R;
import pailaidai.hc.com.mysvgdemo.fragment.ThreeFragement;
import pailaidai.hc.com.mysvgdemo.fragment.TwoFragement;
import pailaidai.hc.com.mysvgdemo.fragment.oneFragement;

public class FragmentActivity extends AppCompatActivity {
    private ViewPager fragment_pager;
    private List<Fragment> list = new ArrayList<>();
    private FragemetAdapter mAaapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fragment);
        initView();
    }

    private void initView() {
        fragment_pager = (ViewPager) findViewById(R.id.fragment_pager);
        list.add(new oneFragement());
        list.add(new TwoFragement());
        list.add(new ThreeFragement());
        mAaapter = new FragemetAdapter(getSupportFragmentManager());
        fragment_pager.setAdapter(mAaapter);
    }


    class FragemetAdapter extends FragmentStatePagerAdapter {

        public FragemetAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int position) {
            return list.get(position);
        }

        @Override
        public int getCount() {
            return list.size();
        }
    }


}
